include("shared.lua")

local Chat = {
	Tree1 = { "Lets see ya' wares", function() ChatFrame:SetVisible( false ) DermaFrame:SetVisible( true ) end },
	Tree2 = { "I havn't got time for this!", function() ChatFrame:SetVisible( false ) end }
}

local Medic = {
	HealthKit = {"models/Items/HealthKit.mdl", "$1,000", "HealthKit x 10", "Description", 1000, "" },
	HealthVial = {"models/healthvial.mdl", "$1,100", "HealthVial x 10", "Description", 1100, "" }
}

function NPCMenu()	

surface.CreateFont( "coolvectica", 20, 400, true, false, "CV20" )

ChatFrame = vgui.Create( "DFrame" )
ChatFrame:SetSize( 600, 150 )
ChatFrame:SetPos( ScrW() / 2 - ChatFrame:GetWide() / 2, ScrH() - ChatFrame:GetTall() - 10 )
ChatFrame:SetTitle( "Chat Menu" )
ChatFrame:SetVisible( true )
ChatFrame:SetDraggable( false )
ChatFrame:ShowCloseButton( false )
ChatFrame:MakePopup()

local ChatTextList = vgui.Create( "DPanelList", ChatFrame )
ChatTextList:SetPos( 10, 32 )
ChatTextList:SetSize( ChatFrame:GetWide() - 20, ChatFrame:GetTall() - 107 )
ChatTextList:SetSpacing( 3 )
ChatTextList:EnableHorizontal( false )
ChatTextList:EnableVerticalScrollbar( true )

local ChatText = vgui.Create( "DLabel", ChatTextList )
ChatText:SetText( "Need anything for your trip?" )
ChatText:SizeToContents()
ChatText:SetWrap( true )
ChatText:Center()

local ChatButtonList = vgui.Create( "DPanelList", ChatFrame )
ChatButtonList:SetPos( 10, 82 )
ChatButtonList:SetSize( ChatFrame:GetWide() - 20, ChatFrame:GetTall() - 92 )
ChatButtonList:SetSpacing( 0 )
ChatButtonList:EnableHorizontal( false )
ChatButtonList:EnableVerticalScrollbar( true )

	 for k,v in pairs( Chat ) do 

		local DermaButton = vgui.Create( "DButton", ChatButtonList )
		DermaButton:SetSize( ChatButtonList:GetWide() - 20, 20 )
		DermaButton:SetPos( 10, 3 )
		DermaButton:SetText( v[1] )
		DermaButton.DoClick = v[2]
		ChatButtonList:AddItem( DermaButton )
	end

	//frame
DermaFrame = vgui.Create( "DFrame" )
DermaFrame:SetSize( ScrW() - 400, ScrH() - 300 )
DermaFrame:SetTitle( "Drug Dealer" )
DermaFrame:SetVisible( false )
DermaFrame:SetDraggable ( false )
DermaFrame:ShowCloseButton( true )
DermaFrame:Center()
DermaFrame:MakePopup()


	//DermaList
local DermaList = vgui.Create( "DPanelList", DermaFrame )
DermaList:SetPos( 10, 32 )
DermaList:SetSize( DermaFrame:GetWide() - 20, DermaFrame:GetTall() - 42 )
DermaList:SetSpacing( 1 )
DermaList:EnableHorizontal( false )
DermaList:EnableVerticalScrollbar( true )

	
	for k, v in pairs(Medic) do 
		
		local DermaPanel = vgui.Create( "DPanel", DermaList )
		DermaPanel:SetSize( DermaList:GetWide(), 100 )
		DermaPanel.Paint = function()
			draw.RoundedBox( 8, 10, 10, DermaPanel:GetWide() - 20, DermaPanel:GetTall() - 10, Color( 100, 95, 95, 255 ))
		end
		
		local SpawnIcon = vgui.Create( "SpawnIcon", DermaPanel)
		SpawnIcon:SetPos( 20, 20 )
		SpawnIcon:SetToolTip( false )
		SpawnIcon:SetModel( v[1] )
		
		local DermaLabel = vgui.Create( "DLabel", DermaPanel )
		DermaLabel:SetPos( 100, 20 )
		DermaLabel:SetText( v[2] )
		DermaLabel:SetFont( "CV20" )
		DermaLabel:SizeToContents()
		DermaLabel:SetColor( Color( 255, 255, 255, 255) )
		
		local DermaLabel2 = vgui.Create( "DLabel", DermaPanel )
		DermaLabel2:SetPos( DermaPanel:GetWide() / 2 - 40, 20 )
		DermaLabel2:SetText( v[3] )
		DermaLabel2:SetFont( "CV20" )
		DermaLabel2:SizeToContents()
		DermaLabel2:SetColor( Color( 255, 255, 255, 255) )
		
		local DermaLabel3 = vgui.Create( "DLabel", DermaPanel )
		DermaLabel3:SetPos( 100, 40 )
		DermaLabel3:SetText( v[4] )
		DermaLabel3:SizeToContents()
		DermaLabel3:SetColor( Color( 255, 255, 255, 255) )
		
		local DermaButton = vgui.Create( "DButton", DermaPanel )
		DermaButton:SetSize( 100, 30 )
		DermaButton:SetPos( DermaPanel:GetWide() - 120, 60 )
		DermaButton:SetText( "Buy!" )
		DermaButton.DoClick = v[5]
		DermaList:AddItem( DermaPanel )
	end
end

usermessage.Hook("DoctorUsed", NPCMenu)